package com.djx.provider.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author dingjunxiong
 * feign redis
 */
@FeignClient(value = "REDIS-9100")
public interface RedisClientService {
    /**
     * 保存字符串
     * @param key
     * @param value
     * @param seconds
     * @return
     */
    @PostMapping(value = "/redis/set")
    void set(@RequestParam("key") String key, @RequestParam("value") String value, @RequestParam("seconds") int seconds);

    /**
     * 获取字符串
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/get")
    String get(@RequestParam("key") String key);

    /**
     * 保存对象
     * @param key
     * @param object
     * @param seconds
     * @return
     */
    @PostMapping(value = "/redis/setObject")
    void setObject(@RequestParam("key") String key, @RequestParam("object") Object object, @RequestParam("seconds") int seconds);

    /**
     * 获取对象
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/getObject")
    Object getObject(@RequestParam("key") String key);

    /**
     * 判断是否存在
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/exists")
    Boolean exists(@RequestParam("key") String key);

    /**
     * 设置过期时间
     * @param key
     * @param seconds
     * @return
     */
    @PostMapping(value = "/redis/expire")
    void expire(@RequestParam("key") String key, @RequestParam("seconds") int seconds);

    /**
     * 删除
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/del")
    void del(@RequestParam("key") String key);

    /**
     * 剩余生存时间
     * @param key
     * @return
     */
    @PostMapping(value = "/redis/ttl")
    Long ttl(@RequestParam("key") String key);
}
